﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using DevExpress.Accessibility;
using System.Windows.Forms;
using System.Drawing;

namespace KNS.Invoice.UI
{
    public class KNSMessageBoxAccessible : ContainerBaseAccessible
    {
         // Methods
    public KNSMessageBoxAccessible(KNSMessageBoxForm form):base(form)
    {
        
    }

    protected override ChildrenInfo GetChildrenInfo()
    {
        ChildrenInfo childrenInfo = base.GetChildrenInfo();
        if (this.Control.Message.Icon != null)
        {
            childrenInfo["Icon"] = 1;
        }
        childrenInfo[ChildType.Text] = 1;
        return childrenInfo;
    }

    protected override string GetName()
    {
        return this.Control.Message.Caption;
    }

    protected override AccessibleRole GetRole()
    {
        return AccessibleRole.Dialog;
    }

    protected override void OnChildrenCountChanged()
    {
        if (this.Control.Message.Icon != null)
        {
            base.AddChild(new MessageIconAccessible(this.Control));
        }
        base.AddChild(new MessageLabelAccessible(this.Control));
        base.OnChildrenCountChanged();
    }

    // Properties
    public KNSMessageBoxForm Control
    {
        get
        {
            return (base.Control as KNSMessageBoxForm);
        }
    }

    public override AccessibleObject Parent
    {
        get
        {
            return this.Control.GetParentAccessible();
        }
    }

    // Nested Types
    protected class MessageIconAccessible : BaseAccessible
    {
        // Fields
        private KNSMessageBoxForm form;

        // Methods
        public MessageIconAccessible(KNSMessageBoxForm form)
        {
            this.form = form;
        }

        protected override AccessibleRole GetRole()
        {
            return AccessibleRole.Graphic;
        }

        // Properties
        public override Rectangle ClientBounds
        {
            get
            {
                return this.form.IconRectangle;
            }
        }
    }

    protected class MessageLabelAccessible : BaseAccessible
    {
        // Fields
        private KNSMessageBoxForm form;

        // Methods
        public MessageLabelAccessible(KNSMessageBoxForm form)
        {
            this.form = form;
        }

        protected override string GetName()
        {
            return this.form.Message.Text;
        }

        protected override AccessibleRole GetRole()
        {
            return AccessibleRole.StaticText;
        }

        // Properties
        public override Rectangle ClientBounds
        {
            get
            {
                return this.form.MessageRectangle;
            }
        }
    }

    }
}
